import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vant, { Lazyload } from 'vant'
import 'vant/lib/index.css'
// 加载全局样式
import './styles/index.less'

// 加载动态设置 REM 基准值
import 'amfe-flexible'

Vue.use(Vant)
Vue.config.productionTip = false
Vue.filter('time', (value) => {
  const date = +new Date(value)
  const date1 = +new Date()
  let s = (date1 - date) / 1000
  if (s < 60) return `${parseInt(s)}秒前`
  s = s / 60
  if (s <= 60) return `${parseInt(s)}分钟前`
  s = s / 60
  if (s <= 24) return `${parseInt(s)}小时前`
  s = s / 24
  if (s <= 30) return `${parseInt(s)}天前`
  s = s / 30
  if (s <= 12) return `${parseInt(s)}月前`
  s = s / 12
  return `${parseInt(s)}年前`
})

Vue.use(Lazyload)
Vue.use(Lazyload, {
  lazyComponent: true
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
